package LogBook;

import LogBook.QSO;

public class HRD {

	public String asString(QSO qso) {
		return element("call", qso.getCallSign())
				+ element("frequency", Double.toString(qso.getFrequency()))
				+ element("mode", qso.getMode())
				+ element("rst_sent", qso.getRST("s"))
				+ element("rst_rcvd", qso.getRST("r"))
				+ element("qso_date", this.date(qso.getTime()))
				+ element("time_on", this.time(qso.getTime()))
				+ element("time_off", this.time(qso.getTime())) + "<EOR>\n";
	}

	private String element(String key, String value) {
		return String.format("<%s:%d>%s ", key, value.length(),
				value);
	}

	private String time(Time time) {
		return String.format("%H%M%S", time);
	}

	private String date(Time time) {
		return String.format("%Y%m%d", time);
	}
}